package cn.tedu._03vehicle.base.ceptors;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.HandlerInterceptor;

import java.time.LocalDateTime;

public class TimeCeptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        LocalDateTime now=LocalDateTime.now();
        int hour=now.getHour();
        if(hour<6||hour>22)
            throw new RuntimeException("只能在6-23点访问");
        return true;
    }
}
